package indi.tshoiasc.simstr.utils;

import org.bukkit.Effect;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;

public class GeneralOperate {
	public static Effect getEffect(int i) {
		if (i == 1) {
			return Effect.BLAZE_SHOOT;
		}
		if (i == 2) {
			return Effect.BOW_FIRE;
		}
		if (i == 3) {
			return Effect.CLICK1;
		}
		if (i == 4) {
			return Effect.EXTINGUISH;
		}
		if (i == 5) {
			return Effect.RECORD_PLAY;
		}
		if (i == 6) {
			return Effect.GHAST_SHOOT;
		}
		if (i == 7) {
			return Effect.GHAST_SHRIEK;
		}
		if (i == 8) {
			return Effect.STEP_SOUND;
		}
		if (i == 9) {
			return Effect.POTION_BREAK;
		}
		return Effect.BLAZE_SHOOT;
	}

	public static Enchantment getEnchantment(int i) {
		if (i == 1) {
			return Enchantment.ARROW_DAMAGE;
		}
		if (i == 2) {
			return Enchantment.ARROW_FIRE;
		}
		if (i == 3) {
			return Enchantment.ARROW_INFINITE;
		}
		if (i == 4) {
			return Enchantment.ARROW_KNOCKBACK;
		}
		if (i == 5) {
			return Enchantment.DAMAGE_ALL;
		}
		if (i == 6) {
			return Enchantment.DAMAGE_ARTHROPODS;
		}
		if (i == 7) {
			return Enchantment.DAMAGE_UNDEAD;
		}
		if (i == 8) {
			return Enchantment.DIG_SPEED;
		}
		if (i == 9) {
			return Enchantment.DURABILITY;
		}
		if (i == 10) {
			return Enchantment.FIRE_ASPECT;
		}
		if (i == 11) {
			return Enchantment.KNOCKBACK;
		}
		if (i == 12) {
			return Enchantment.LOOT_BONUS_BLOCKS;
		}
		if (i == 13) {
			return Enchantment.LOOT_BONUS_MOBS;
		}
		if (i == 14) {
			return Enchantment.LUCK;
		}
		if (i == 15) {
			return Enchantment.LURE;
		}
		if (i == 16) {
			return Enchantment.OXYGEN;
		}
		if (i == 17) {
			return Enchantment.PROTECTION_ENVIRONMENTAL;
		}
		if (i == 18) {
			return Enchantment.PROTECTION_EXPLOSIONS;
		}
		if (i == 19) {
			return Enchantment.PROTECTION_FALL;
		}
		if (i == 20) {
			return Enchantment.PROTECTION_FIRE;
		}
		if (i == 21) {
			return Enchantment.PROTECTION_PROJECTILE;
		}
		if (i == 22) {
			return Enchantment.SILK_TOUCH;
		}
		if (i == 23) {
			return Enchantment.THORNS;
		}
		if (i == 24) {
			return Enchantment.WATER_WORKER;
		}
		return null;
	}

	public static int getLevel(ItemStack item) {
		int level = 0;
		StringBuffer sb = new StringBuffer("§b[强化等级]:§6§l");
		int index = ItemOperate.lookupLoreIndex(item, "[强化等级]:");
		if (index == -1) {
			return 0;
		}
		for (int i = 1; i <= 10; i++) {
			sb.append("✡");
			if (((String) item.getItemMeta().getLore().get(index)).equals(sb.toString())) {
				level = i;
				break;
			}
		}
		return level;
	}

	public static void setLevel(ItemStack item, int level) {
		StringBuffer sb = new StringBuffer("§b[强化等级]:§6§l");
		for (int i = 1; i <= level; i++) {
			sb.append("✡");
		}
		int index = ItemOperate.lookupLoreIndex(item, "§b[强化等级]:§6§l");
		if (index == -1) {
			ItemOperate.addLore(item, sb.toString());
		} else {
			ItemOperate.setLore(item, index, sb.toString());
		}
	}

	public static boolean random(int rand) {
		int Random = (int) (Math.random() * 100.0D) + 1;
		if (Random <= rand) {
			return true;
		}
		return false;
	}
}
